package cn.tedu.csmall.order.webapi.controller;

import cn.tedu.csmall.commons.pojo.order.dto.OrderAddDTO;
import cn.tedu.csmall.commons.restful.JsonResult;
import cn.tedu.csmall.order.service.IOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/base/order")
@Api(tags = "订单模块")
public class CartController {


    @Autowired
    private IOrderService orderService;


    @PostMapping("/add")
    @ApiOperation("新增订单")
    public JsonResult<Void> addOrder(OrderAddDTO orderAddDTO){

        orderService.addNewOrder(orderAddDTO);
        return JsonResult.ok("新增成功！");
    }
    @PostMapping("/delete")
    @ApiOperation("删除订单中商品")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户ID",name = "userId",example = "UU100"),
            @ApiImplicitParam(value = "商品编号",name = "commodityCode",example = "PC100")
    })
    public JsonResult<Void> delete(String userId,String commodityCode){
        orderService.deleteOrder(userId, commodityCode);
        return JsonResult.ok("删除成功！！");
    }

}
